package com.demo;

import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;


class MyCallable implements Callable<Integer>{
	@Override
	public Integer call() throws Exception {
		int num = new Random().nextInt(100);
		System.out.println("===callable=="+num);
		return  num;
	}
}

public class CallableAndFutrue {
	public static void main(String[] args) throws Exception {
		MyCallable call = new MyCallable(); //执行业务对象
		FutureTask<Integer> task = new FutureTask<Integer>(call);
		new Thread(task).start();
		Thread.sleep(1000);
		Integer num  =task.get();
		System.out.println("产生的随机数:"+num);
	}

}
